<?php

/**
 * @author xuananh.ho
 * @copyright 2012
 */
 
    //include "../util/dataUtil.php";
        //so dong hien thi tren mot trang
        $hienthi = 5;
        //tinh tong so trang
        if(isset($_GET['page']) && (int)$_GET['page']){
            $page = $_GET['page'];
        }else{
            $sodong = "select id_NhanVien from nhanvien";
            $kq=executeQuery($sodong);
            $kq_sodong =mysql_num_rows($kq);
            $so = $kq_sodong;
            if($so>$hienthi){
                $page = ceil($so/$hienthi);
            }else{
                $page = 1;
            }
        }
        //vitri bat dau hien thi
        $vitri = (isset($_GET['vitri'])&& (int)$_GET['vitri']) ? $_GET['vitri']:0;    

            
            $sql = "SELECT a.id_NhanVien,b.HoTen,b.GioiTinh,date_format(b.NgaySinh,'%d/%m/%Y') as NgaySinh,
		                  b.NoiSinh,b.DiaChi,b.DienThoai,b.Email,b.HinhAnh,date_format(b.NgayBDLV,'%d/%m/%Y') as NgayBDLV,
		                  a.MaVaiTro,c.TenVaiTro,a.MaPhong,d.TenPhong,a.MaTinhTrang,e.TinhTrang,a.MaNQL,f.HoTen as TenNQL,b.GhiChu
                    FROM NhanVien a inner join ChiTietNhanVien b on a.id_NhanVien = b.id_NhanVien
                                inner join VaiTro c on a.MaVaiTro = c.ID
                                inner join PhongBan d on a.MaPhong = d.MaPhong
                                inner join TinhTrang e on a.MaTinhTrang = e.ID
                                inner join ChiTietNhanVien f on a.MaNQL = f.id_NhanVien
                    order by a.id_NhanVien asc limit $vitri,$hienthi ";
        
            $nhanVien = executeQuery($sql);
        //}
        
       /* if($actionType == "editNV"){
            $id_NhanVien = $_GET["id_NhanVien"];
                    $matKhau = "";
                    $tenVaiTro = "";
                    $tenPhong = "";
                    $tinhTrang = "";
                    $maNQL = "";
                    $hoTen = "";
                    $gioiTinh = "";
                    $ngaySinh = "";
                    $noiSinh = "";
                    $diaChi = "";
                    $dienThoai = "";
                    $email = "";
                    $ngayBDLV = "";
                    $luong = "";
                    $ghiChu = "";
                    
                    $sql = "SELECT a.id_NhanVien,b.HoTen,b.GioiTinh,date_format(b.NgaySinh,'%d/%m/%Y') as NgaySinh,
		                          b.NoiSinh,b.DiaChi,b.DienThoai,b.Email,b.HinhAnh,date_format(b.NgayBDLV,'%d/%m/%Y') as NgayBDLV,
		                          a.MaVaiTro,c.TenVaiTro,a.MaPhong,d.TenPhong,a.MaTinhTrang,e.TinhTrang,a.MaNQL,f.HoTen as TenNQL,b.GhiChu
                            FROM NhanVien a inner join ChiTietNhanVien b on a.id_NhanVien = b.id_NhanVien
                                        	inner join VaiTro c on a.MaVaiTro = c.ID
                                        	inner join PhongBan d on a.MaPhong = d.MaPhong
                                        	inner join TinhTrang e on a.MaTinhTrang = e.ID
                                        	inner join ChiTietNhanVien f on a.MaNQL = f.id_NhanVien
                            WHERE a.id_NhanVien = '$id_NhanVien'";
                            
                    $nhanVien1 = executeQuery($sql);
        }*/
        
        
?>